home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / human interface toolbox / packagetool / sample package / htmlsample sources / history.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  6.6 KB  |  161 lines

  1. /*
  2.     File: History.h
  3.     
  4.     Description:
  5.         This file contains routine prototypes and type declarations that can
  6.     be used to access the routines defined in History.c  These routines
  7.     are used to store visitled links.
  8.     
  9.     HTMLSample is an application illustrating how to use the new
  10.     HTMLRenderingLib services found in Mac OS 9. HTMLRenderingLib
  11.     is Apple's light-weight HTML rendering engine capable of
  12.     displaying HTML files.
  13.  
  14.     Copyright:
  15.         © Copyright 1999 Apple Computer, Inc. All rights reserved.
  16.     
  17.     Disclaimer:
  18.         IMPORTANT:  This Apple software is supplied to you by Apple Computer, Inc.
  19.         ("Apple") in consideration of your agreement to the following terms, and your
  20.         use, installation, modification or redistribution of this Apple software
  21.         constitutes acceptance of these terms.  If you do not agree with these terms,
  22.         please do not use, install, modify or redistribute this Apple software.
  23.  
  24.         In consideration of your agreement to abide by the following terms, and subject
  25.         to these terms, Apple grants you a personal, non-exclusive license, under Apple’s
  26.         copyrights in this original Apple software (the "Apple Software"), to use,
  27.         reproduce, modify and redistribute the Apple Software, with or without
  28.         modifications, in source and/or binary forms; provided that if you redistribute
  29.         the Apple Software in its entirety and without modifications, you must retain
  30.         this notice and the following text and disclaimers in all such redistributions of
  31.         the Apple Software.  Neither the name, trademarks, service marks or logos of
  32.         Apple Computer, Inc. may be used to endorse or promote products derived from the
  33.         Apple Software without specific prior written permission from Apple.  Except as
  34.         expressly stated in this notice, no other rights or licenses, express or implied,
  35.         are granted by Apple herein, including but not limited to any patent rights that
  36.         may be infringed by your derivative works or by other works in which the Apple
  37.         Software may be incorporated.
  38.  
  39.         The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  40.         WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  41.         WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  42.         PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  43.         COMBINATION WITH YOUR PRODUCTS.
  44.  
  45.         IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  46.         CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  47.         GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  48.         ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
  49.         OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
  50.         (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
  51.         ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  52.  
  53.     Change History (most recent first):
  54.         Wed, Dec 22, 1999 -- created
  55. */
  56.  
  57.  
  58.  
  59. #ifndef __HISTORY__
  60. #define __HISTORY__
  61.  
  62. #include <Types.h>
  63. #include <Menus.h>
  64.  
  65.  
  66. /* HistoryDataHandle defines the data type we are using
  67.     for storing historical information about visited links.
  68.     A history is maintained as a list/stack where we can
  69.     move backwards and forwards referencing elements as
  70.     required.  The only difference between a history and
  71.     a stack is that if we add a new element to the history,
  72.     then all elements beyond the current reference are
  73.     deleted before the new element is added. */
  74. typedef struct HistoryData HistoryData;
  75. typedef HistoryData *HistoryDataPtr, **HistoryDataHandle;
  76.  
  77.  
  78. /* NewHistory creats a new history and returns
  79.     a handle to it. */
  80. HistoryDataHandle NewHistory(void);
  81.  
  82.  
  83. /* DisposeHistory disposes of a history and all of the
  84.     structures allocated for it. */
  85. void DisposeHistory(HistoryDataHandle hd);
  86.  
  87.  
  88. /* AddToHistory adds a new element to the history.  Both
  89.     the URL and the printed representation of its url
  90.     are stored.  NOTE:  if we have called GoBack a few times
  91.     before this call, then those previously viewed items
  92.     are removed from the history. This is so if we choose
  93.     GoBack again, then we will arrive at the same link we
  94.     are looking at now.  */
  95. OSErr AddToHistory(HistoryDataHandle hd, char const* url, StringPtr printName);
  96.  
  97.  
  98. /* InHistory returns true if the URL is among the urls
  99.     currently stored in the history. */
  100. Boolean InHistory(HistoryDataHandle hd, char const* url);
  101.  
  102. /* CanGoBack returns true if it makes sense to call the
  103.     GoBack command.  i.e. if there are one or more links
  104.     in the history beyond the current one. */
  105. Boolean CanGoBack(HistoryDataHandle hd);
  106.  
  107. /* GoBack copies the previous url in the history
  108.     into a new handle and returns that handle in
  109.     *url.  It is the caller's responsibility to dispose
  110.     of the handle after it has been used. */
  111. OSErr GoBack(HistoryDataHandle hd, Handle *url);
  112.  
  113.  
  114. /* CanGoForward returns true if it makes sense to call the
  115.     GoForward command.  i.e. if there are one or more links
  116.     in the history ahead of the current one.  This can only
  117.     happen after the user has chosen GoBack one or more
  118.     times. */
  119. Boolean CanGoForward(HistoryDataHandle hd);
  120.  
  121.  
  122. /* GoForward copies the next url in the history
  123.     into a new handle and returns that handle in
  124.     *url.  It is the caller's responsibility to dispose
  125.     of the handle after it has been used. */
  126. OSErr GoForward(HistoryDataHandle hd, Handle *url);
  127.  
  128.  
  129. /* CanGoHome returns true if it makes sense to call the
  130.     GoHome command.  i.e. if there are one or more links
  131.     in the history.  This can only happen after AddToHistory
  132.     has been called one or more times. */
  133. Boolean CanGoHome(HistoryDataHandle hd);
  134.  
  135.  
  136. /* GoBack copies the first url in the history
  137.     into a new handle and returns that handle in
  138.     *url.  It is the caller's responsibility to dispose
  139.     of the handle after it has been used. */
  140. OSErr GoHome(HistoryDataHandle hd, Handle *url);
  141.  
  142.  
  143. /* AppendHistoryToMenu rebuilds the Go menu adding items to the
  144.     bottom of the menu according to the items in the
  145.     history.  The names of the items are the same as
  146.     the printNames provided in the AddToHistory command. */
  147. OSErr AppendHistoryToMenu(HistoryDataHandle hd, MenuHandle theMenu);
  148.  
  149.  
  150. /* GoToMenuItem copies the itemIndex'th url in the history
  151.     into a new handle and returns that handle in
  152.     *url.  It is the caller's responsibility to dispose
  153.     of the handle after it has been used.  This routine
  154.     should only be called after a menu selection has
  155.     been made in a menu built by AppendHistoryToMenu.  */
  156. OSErr GoToMenuItem(HistoryDataHandle hd, Handle *url, short itemIndex);
  157.  
  158.  
  159. #endif
  160.  
  161.